/*
 * Copyright (C) 2018 Logos Technology Ltd.
 */

package com.logos.tool;

import android.graphics.PointF;

import java.util.ArrayList;
import java.util.List;

/**
 * @author guoyalong
 * 获取圆上面的point
 */
public class CirclePoint {
    /**
     * 获取圆上面的点
     *
     * @param centerPoint 中心点
     * @param radius      半径
     * @param startAngle  起始角度
     * @param endAngle    终止角度
     * @return list
     */
    public static List<PointF> getCirclePointList(PointF centerPoint,
                                                  float radius, int startAngle, int endAngle) {
        List<PointF> pointList = new ArrayList<>();
        float poorAngle = (endAngle - startAngle) / 50f;
        for (int i = 1; i < 50; i++) {
            PointF point = new PointF();
            point.x = (int) (centerPoint.x + radius
                    * Math.cos(Math.toRadians(startAngle + i * poorAngle)));
            point.y = (int) (centerPoint.y + radius
                    * Math.sin(Math.toRadians(startAngle + i * poorAngle)));
            pointList.add(point);
        }
        return pointList;
    }
}
